import request from '@/utils/request'
import cloudConstant from "@/utils/cloudConstant";
const api_name = cloudConstant.SYSTEM_MENU;

export default {
  /**获取所有菜单*/
  getNestedTreeList() {
    return request({
      url: `${api_name}/getAllMenu`,
      method: 'get'
    })
  },
  /**删除菜单*/
  removeById(id:string) {
    return request({
      url: `${api_name}/removeMenu/${id}`,
      method: "post"
    })
  },
  /**保存菜单*/
  saveMenu(menu:object) {
    return request({
      url: `${api_name}/saveMenu`,
      method: "post",
      data: menu
    })
  },
  /**更新菜单*/
  update(menu:object) {
    return request({
      url: `${api_name}/updateMenu`,
      method: "post",
      data: menu
    })
  },
  /**根据角色获取菜单*/
  getMenuWithRoleId(roleId:object) {
    return request({
      url: `${api_name}/getMenuWithRoleId/${roleId}`,
      method: 'get'
    })
  },
  /**根据角色分配权限*/
  doAssignRoleAuth(roleId:string, menus:string) {
    return request({
      url: `${api_name}/doAssignRoleAuth`,
      method: "post",
      params: {roleId, menus}
    })
  },
  updateIcon(id:string,symbol:string)
  {
    return request({
      url:`${api_name}/updateIcon`,
      method:"post",
      params:{id,icon:symbol}
    })
  }
}
